<% layout('/layouts/default.html', {title: '医师管理', libs: ['validate','fileupload']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-trophy"></i> ${text(doctor.isNewRecord ? '新增医师' : '编辑医师')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${doctor}" action="${ctx}/fl/doctor/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="id"/>

				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required ">*</span> ${text('医师名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:input path="name" maxlength="200" class="form-control required "
									remote="${ctx}/fl/doctor/checkDoctorName?oldDoctorName=${doctor.name}"
									data-msg-remote="${text('医师名称已存在')}"/>
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required ">*</span> ${text('英文名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:input path="enName" maxlength="200" class="form-control required "/>
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required ">*</span> ${text('性别')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:select path="sex" dictType="sys_user_sex" blankOption="true" class="form-control required"/>
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required ">*</span> ${text('职称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:select path="title" dictType="fl_doctor_title" blankOption="true" class="form-control required"/>
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required ">*</span> ${text('简介')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:textarea path="description" rows="4" maxlength="2000" class="form-control required "/>
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required ">*</span> ${text('英文简介')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:textarea path="enDescription" rows="4" maxlength="2000" class="form-control required "/>
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required ">*</span> ${text('所属诊所')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:select path="clinics" items="${clinicList}" itemLabel="name" itemValue="id" blankOption="true" multiple="true" class="form-control required "/>
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required ">*</span> ${text('所属科室')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:select path="rooms" items="${nowList}" itemLabel="dictLabel" itemValue="dictValue" blankOption="true"  multiple="true" class="form-control required"/>									
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('图片上传')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:fileupload id="uploadPicture" returnPath="true" filePathInputId="picture" fileNameInputId="pictureName"
										uploadType="image" readonly="false" isMini="false"  bizKey="${doctor.id}" bizType="content_image"/>
								<#form:input readonly="true" path="picture" class="form-control"/>
								<#form:hidden path="pictureName"/>
							</div>
						</div>
					</div>
					
				</div>

				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('排班信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:fileupload id="uploadFile" returnPath="true" filePathInputId="schedulingInformation" fileNameInputId="schedulingInformationName"
										uploadType="all" readonly="false" maxUploadNum="3" isMini="false" bizKey="${doctor.id}" bizType="content_file"/>
								<#form:input readonly="true" path="schedulingInformation" class="form-control"/>
								<#form:hidden path="schedulingInformationName"/>
							</div>
						</div>
					</div>
					
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-9">
						<% if (hasPermi('fl:doctor:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#clinics").change(function () {
		var clinics = $("#clinics").val();
		var rooms = '${doctor.rooms}';
		if(clinics != null){
			$.post("${ctx}/fl/doctor/departmentList?clinics="+clinics, function (reply) {

                $("#rooms").empty();
                $("#rooms").append("<option value=></option>");
                if (reply && reply.length > 0) {
                    $.each(reply, function (idx, item) {
                    	if(rooms.indexOf(item.dictValue)>=0){
                        $("#rooms").append("<option value=" + item.dictValue + " selected>" + item.dictLabel + "</option>");
                      }else{
                      	$("#rooms").append("<option value=" + item.dictValue + ">" + item.dictLabel + "</option>");
                      }
                    });                              
                }

         });
		}
});

$("#inputForm").validate({
	submitHandler: function(form){
		
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>
